package com.eflow.engine.listener;

import com.eflow.model.domain.EflowTask;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;

import java.util.Map;

/**
 * @author hui se
 * @description 流程监听器
 * @create 2021-07-11 18:46
 **/
public interface IProcessListener {

    /**
     * 在这获取初始化变量，最好需要在开始初始化的变量都放在这里，因为发起流程时获取下一步节点需要使用
     * @param businessId
     * @return
     */
     Map<String,Object> getVariables(String businessId);

    /**
     * 流程、待办的标题，在这里处理
     * @param taskId
     * @param processInstanceId
     * @param execution
     * @return
     */
     String getTitle(String taskId, String processInstanceId, DelegateExecution execution);

    /**
     * 流程开始
     * @param processInstanceId
     * @param execution
     * @param variables
     */
    void start(String processInstanceId, DelegateExecution execution, Map variables);

    /**
     * 流程结束
     * @param processInstanceId
     * @param execution
     */
    void end(String processInstanceId, DelegateExecution execution);

    /**
     * 完成任务
     * @param taskId
     * @param processInstanceId
     * @param execution
     */
    void completed(String taskId, String processInstanceId, DelegateExecution execution);

    /**
     * 业务类型
     * @return
     */
    String businessType();


    /**
     * 退回
     * @param taskId
     * @param processInstanceId
     * @param execution
     */
    void rejected(String taskId, String processInstanceId, DelegateExecution execution);

    void taskDeleted(TaskEntity task, String processInstanceId, ExecutionEntity executionEntity);

    void taskAssigned(EflowTask eflowTask,TaskEntity task, String processInstanceId, ExecutionEntity entity);

    void processDelete(String processInstanceId, ExecutionEntity executionEntity);

}
